<pre>
<tt>
<font color="#FF0000">/**	\author    coidgen 0.7.4</font>
<font color="#FF0000">	\version    (0.0 build 1)</font>
<font color="#FF0000">	\date      </font>
<font color="#FF0000">	\brief     </font>
<font color="#FF0000">*/</font>



<font color="#000080">#include</font> <font color="#000000">"example_client.h"</font>




<font color="#0000FF">namespace</font> coid <font color="#000080">{</font>

<font color="#0000FF">struct</font> COID_TABLE_example_0_0 <font color="#000080">{</font>
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*disconnect)();
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*read1__0)( FOO_STRUCT &amp; list );
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*read2__1)( FOO_STRUCT * &amp; list );
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*send__2)( <font color="#0000FF">int</font> &amp; ref, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; command, binstreambuf &amp; reply ) <font color="#0000FF">const</font>;
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*remap_fnc__3)( REMAP_EXAMPLE_clientside &amp; remapped_arg );
	<font color="#0000FF">opcd</font> (COID_TABLE_example_0_0::*get_ptr__4)( FOO_STRUCT ** f );
<font color="#000080">}</font>;

<font color="#000080">}</font>	<font color="#FF0000">/// namespace coid</font>



<font color="#000080">#define</font> ___COID_CONNECTWITHIN_TRY		<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#define</font> ___COID_CONNECTWITHIN_CATCH	<font color="#000080">}</font> <font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> ___coid_err ) <font color="#000080">{</font><font color="#0000FF">return</font> ___coid_err;<font color="#000080">}</font>\
										<font color="#0000FF">catch</font>(...) <font color="#000080">{</font> <font color="#0000FF">return</font> ersFE_EXCEPTION <font color="#000000">"client method exception"</font>; <font color="#000080">}</font>
<font color="#000080">#define</font> ___COID_CONNECT_TRY		<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#define</font> ___COID_CONNECT_CATCH		<font color="#000080">}</font> <font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> ___coid_err ) <font color="#000080">{</font><font color="#0000FF">delete</font> _coid_bstream; <font color="#0000FF">return</font> ___coid_err;<font color="#000080">}</font>\
									<font color="#0000FF">catch</font>( ThreadException &amp; ) <font color="#000080">{</font> <font color="#0000FF">delete</font> _coid_bstream; <font color="#0000FF">throw</font>; <font color="#000080">}</font>\
									<font color="#0000FF">catch</font>(...) <font color="#000080">{</font> <font color="#0000FF">delete</font> _coid_bstream; <font color="#0000FF">return</font> ersFE_EXCEPTION <font color="#000000">"client method exception"</font>; <font color="#000080">}</font>





<font color="#0000FF">const</font> version <font color="#000000">COID_version_example_0_0(</font> <font color="#000000">""</font>, <font color="#00D000">0</font>, <font color="#00D000">0</font>, <font color="#00D000">1</font> );

<font color="#0000FF">static</font> COID_NICK g_coid_nick;

<font color="#0000FF">static</font> COID_TABLE_example_0_0 * coid_interprocess_vtbl = NULL;
<font color="#0000FF">static</font> COID_TABLE_example_0_0 * coid_remote_vtbl = NULL;
<font color="#0000FF">static</font> comm_mutex coid_table_mx;

<font color="#0000FF">struct</font> TABLE_REMOVER_example_0_0 <font color="#000080">{</font>
	~<font color="#000000">TABLE_REMOVER_example_0_0(</font>) <font color="#000080">{</font><font color="#0000FF">delete</font> coid_interprocess_vtbl; <font color="#0000FF">delete</font> coid_remote_vtbl;<font color="#000080">}</font>
<font color="#000080">}</font>;
<font color="#0000FF">static</font> TABLE_REMOVER_example_0_0	example_0_0_table_trash;




<font color="#0000FF">namespace</font> coid <font color="#000080">{</font>

<font color="#0000FF">enum</font> <font color="#000080">{</font>	<font color="#FF0000">/// command ids, format is: COID_classname_fncname_fncid</font>
	COID_example_read1_0 = <font color="#00D000">0</font>,
	COID_example_read2_1 = <font color="#00D000">1</font>,
	COID_example_send_2 = <font color="#00D000">2</font>,
	COID_example_remap_fnc_3 = <font color="#00D000">3</font>,
	COID_example_get_ptr_4 = <font color="#00D000">4</font>
<font color="#000080">}</font>;




<font color="#0000FF">static</font> <font color="#0000FF">uint</font> COID_method_flags_example[<font color="#00D000">5</font>] = <font color="#000080">{</font>
	<font color="#00D000">0x70100</font>,
	<font color="#00D000">0x70100</font>,
	<font color="#00D000">0x70101</font>,
	<font color="#00D000">0x70000</font>,
	<font color="#00D000">0x10000</font>
<font color="#000080">}</font>;




<font color="#FF0000">/***************************************************************************</font>
<font color="#FF0000">example_localclient</font>
<font color="#FF0000">***************************************************************************/</font>

<font color="#0000FF">class</font> example_localclient : <font color="#0000FF">public</font> COID_CLIENT
<font color="#000080">{</font>
<font color="#0000FF">public</font>:
	<font color="#000000">example_localclient(</font> netstream * b, binstream * b2 ) : <font color="#000000">COID_CLIENT(</font>b, b2) <font color="#000080">{</font><font color="#000080">}</font>
	<font color="#0000FF">void</font> <font color="#000000">coid_throw(</font>);


	<font color="#0000FF">opcd</font> <font color="#000000">read1(</font> FOO_STRUCT &amp; list );
	<font color="#0000FF">opcd</font> <font color="#000000">read2(</font> FOO_STRUCT &amp; list );
	<font color="#0000FF">opcd</font> <font color="#000000">send(</font> <font color="#0000FF">int</font> &amp; ref, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; command, binstreambuf &amp; reply ) <font color="#0000FF">const</font>;
	<font color="#0000FF">opcd</font> <font color="#000000">remap_fnc(</font> REMAP_EXAMPLE_clientside &amp; remapped_arg );
<font color="#FF0000">// 	opcd get_ptr( FOO_STRUCT ** f );</font>
<font color="#000080">}</font>;



<font color="#FF0000">/// fake function:</font>
<font color="#0000FF">void</font> example_localclient::<font color="#000000">coid_throw(</font>) <font color="#000080">{</font><font color="#0000FF">throw</font> ersFE_EXCEPTION;<font color="#000080">}</font>


<font color="#0000FF">typedef</font> <font color="#0000FF">void</font> (example_localclient::*coid_fnc)();

<font color="#000080">#define</font> <font color="#000000">COID_CLIENT_CREATE_HOOK(</font>M,i,t,tc)\
	<font color="#0000FF">if</font>( COID_method_flags_example[i] &amp; coid_stream_flags ) ((coid_fnc *) table)[t] = (coid_fnc) (tc) &amp;example_localclient::M;\
	<font color="#0000FF">else</font> ((coid_fnc *) table)[t] = (coid_fnc) &amp;example_localclient::coid_throw;

<font color="#000080">#define</font> <font color="#000000">COID_CLIENT_CREATE_DISCONNECT_HOOK(</font>t)\
	((coid_fnc *) table)[t] = (coid_fnc) &amp;example_localclient::disconnect;





<font color="#0000FF">void</font> <font color="#0000FF">inline</font> <font color="#000000">coid_init_table(</font> <font color="#0000FF">uint</font> coid_stream_flags, COID_TABLE_example_0_0 *&amp; table )
<font color="#000080">{</font>
	table = <font color="#0000FF">new</font> COID_TABLE_example_0_0;

	<font color="#0000FF">ulong</font> coid_table_index = <font color="#00D000">0</font>;
	<font color="#000000">COID_CLIENT_CREATE_DISCONNECT_HOOK(</font> coid_table_index++ )
	<font color="#000000">COID_CLIENT_CREATE_HOOK(</font> read1, <font color="#00D000">0</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example_localclient::*)( FOO_STRUCT &amp;  ) )
	((coid_fnc *) table)[coid_table_index++] = (coid_fnc) &amp;example_localclient::coid_throw;  <font color="#FF0000">// 'read2' is not called through this table</font>
	<font color="#000000">COID_CLIENT_CREATE_HOOK(</font> send, <font color="#00D000">2</font>, coid_table_index++, <font color="#0000FF">opcd</font> (example_localclient::*)( <font color="#0000FF">int</font> &amp; , <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; , binstreambuf &amp;  ) <font color="#0000FF">const</font> )
	((coid_fnc *) table)[coid_table_index++] = (coid_fnc) &amp;example_localclient::coid_throw;  <font color="#FF0000">// 'remap_fnc' is not called through this table</font>
	((coid_fnc *) table)[coid_table_index++] = (coid_fnc) &amp;example_localclient::coid_throw;  <font color="#FF0000">// 'get_ptr' is direct only</font>
<font color="#000080">}</font>






<font color="#0000FF">opcd</font> example_localclient::<font color="#000000">read1(</font> FOO_STRUCT &amp; list )
<font color="#000080">{</font>
	*_coid_bstream &lt;&lt; (<font color="#0000FF">ulong</font>) COID_example_read1_0;
	*_coid_bstream &lt;&lt; _coid_inst_id;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	_coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>
	*_coid_bstream &gt;&gt; list;

	_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);

	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>



<font color="#0000FF">opcd</font> example_localclient::<font color="#000000">read2(</font> FOO_STRUCT &amp; list )
<font color="#000080">{</font>
	*_coid_bstream &lt;&lt; (<font color="#0000FF">ulong</font>) COID_example_read2_1;
	*_coid_bstream &lt;&lt; _coid_inst_id;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	_coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>
	*_coid_bstream &gt;&gt; list;

	_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);

	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>



<font color="#0000FF">opcd</font> example_localclient::<font color="#000000">send(</font> <font color="#0000FF">int</font> &amp; ref, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; command, binstreambuf &amp; reply ) <font color="#0000FF">const</font>
<font color="#000080">{</font>
	*_coid_bstream &lt;&lt; (<font color="#0000FF">ulong</font>) COID_example_send_2;
	*_coid_bstream &lt;&lt; _coid_inst_id;
	*_coid_bstream &lt;&lt; ref;
	*_coid_bstream &lt;&lt; command;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	_coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>
	*_coid_bstream &gt;&gt; ref;
	*_coid_bstream &gt;&gt; reply;

	_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);

	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>



<font color="#0000FF">opcd</font> example_localclient::<font color="#000000">remap_fnc(</font> REMAP_EXAMPLE_clientside &amp; remapped_arg )
<font color="#000080">{</font>
	*_coid_bstream &lt;&lt; (<font color="#0000FF">ulong</font>) COID_example_remap_fnc_3;
	*_coid_bstream &lt;&lt; _coid_inst_id;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	_coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>
	*_coid_bstream &gt;&gt; remapped_arg;

	_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);

	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>

<font color="#FF0000">// method 'get_ptr' is direct only</font>



<font color="#FF0000">/***************************************************************************</font>
<font color="#FF0000">example_client</font>
<font color="#FF0000">***************************************************************************/</font>

example_client::<font color="#000000">example_client(</font>) : <font color="#000000">_me(</font>NULL), <font color="#000000">_vtbl(</font>NULL), <font color="#000000">_conn_data(</font><font color="#00D000">0</font>)
<font color="#000080">{</font>
	netSubsystem::<font color="#000000">instance(</font>);
<font color="#000080">}</font>
example_client::~<font color="#000000">example_client(</font>)
<font color="#000080">{</font>
	<font color="#000000">disconnect(</font>);
<font color="#000080">}</font>
example_client::<font color="#000000">example_client(</font> <font color="#0000FF">const</font> example_client &amp; c ) <font color="#000080">{</font><font color="#0000FF">throw</font> ersFE_EXCEPTION;<font color="#000080">}</font>
example_client &amp; example_client::<font color="#0000FF">operator</font> = ( <font color="#0000FF">const</font> example_client &amp; c ) <font color="#000080">{</font><font color="#0000FF">throw</font> ersFE_EXCEPTION; <font color="#0000FF">return</font> *<font color="#0000FF">this</font>;<font color="#000080">}</font>

<font color="#0000FF">void</font> example_client::<font color="#000000">destroy_me(</font>)
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) != ConnectFlags::fACCESS_MODE_DIRECT ) <font color="#0000FF">delete</font> _me;
	_me = NULL;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">disconnect(</font>)
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( ! <font color="#000000">is_connected(</font>) )
		<font color="#0000FF">return</font> <font color="#00D000">0</font>;
	<font color="#000000">DASSERT(</font> _mx_reg.<font color="#000000">is_valid(</font>) );
	comm_mutex &amp; lowlevelmx = _mx_reg._mxc-&gt;_mx;
	<font color="#0000FF">bool</font> last = <font color="#0000FF">false</font>;
	<font color="#0000FF">opcd</font> coid_err;
	<font color="#0000FF">try</font> <font color="#000080">{</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#000000">DASSERT(</font> _me );
		coid_err = ((<font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_DIRECT ? (COID_TABLE_example_0_0 *) <font color="#0000FF">this</font> : _me)-&gt;*(_vtbl-&gt;disconnect)) ();
		<font color="#000000">destroy_me(</font>);
		<font color="#0000FF">if</font>( _mx_reg.<font color="#000000">counter_fast(</font>) == <font color="#00D000">1</font> ) <font color="#000080">{</font>
			_mx_reg.<font color="#000000">disable_fast(</font>);
			lowlevelmx.<font color="#000000">unlock(</font>);
			__coid__mxg.<font color="#000000">eject(</font>);
			last = <font color="#0000FF">true</font>;
		<font color="#000080">}</font>
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>
		<font color="#000000">destroy_me(</font>); coid_err = e;
	<font color="#000080">}</font>

	<font color="#0000FF">if</font>( last ) <font color="#000080">{</font>
<font color="#000080">#ifdef</font> _DEBUG
		<font color="#0000FF">const</font> <font color="#0000FF">int</font> max = <font color="#00D000">0xFFFF</font>;
<font color="#000080">#else</font>
		<font color="#0000FF">const</font> <font color="#0000FF">int</font> max = <font color="#00D000">10</font>;
<font color="#000080">#endif</font>
		<font color="#0000FF">int</font> i=<font color="#00D000">0</font>;
		<font color="#0000FF">for</font>( ; i&lt;max; i++ ) <font color="#000080">{</font>
			<font color="#0000FF">if</font>( lowlevelmx.<font color="#000000">try_lock(</font>) ) <font color="#000080">{</font>lowlevelmx.<font color="#000000">unlock(</font>); <font color="#0000FF">break</font>;<font color="#000080">}</font>
			<font color="#000000">sysMilliSecondSleep(</font> <font color="#00D000">10</font> );
		<font color="#000080">}</font>
		<font color="#0000FF">if</font>( i == max ) <font color="#0000FF">throw</font> ersFE_EXCEPTION;
	<font color="#000080">}</font>

	_mx_reg.<font color="#000000">destroy_all(</font>);
	_vtbl = NULL;
	<font color="#000000">set_connection_type(</font> <font color="#00D000">0</font> );
	<font color="#0000FF">return</font> coid_err;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">get_last_error(</font>) <font color="#0000FF">const</font>
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( ! <font color="#000000">is_connected(</font>) ) <font color="#0000FF">return</font> <font color="#00D000">0</font>;
	<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_REMOTE ) <font color="#0000FF">return</font> ((COID_CLIENT *) _me)-&gt;<font color="#000000">get_last_error(</font>);
	<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_INTERPROCESS ) <font color="#0000FF">return</font> ((COID_CLIENT *) _me)-&gt;<font color="#000000">get_last_error(</font>);
	<font color="#0000FF">return</font> <font color="#00D000">0</font>;
<font color="#000080">}</font>

<font color="#0000FF">void</font> example_client::<font color="#000000">set_last_error(</font> <font color="#0000FF">opcd</font> e )
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( ! <font color="#000000">is_connected(</font>) ) <font color="#0000FF">return</font>;
	<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_REMOTE ) ((COID_CLIENT *) _me)-&gt;<font color="#000000">set_last_error(</font> e );
	<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_INTERPROCESS ) ((COID_CLIENT *) _me)-&gt;<font color="#000000">set_last_error(</font> e );
<font color="#000080">}</font>

<font color="#0000FF">inline</font> <font color="#0000FF">bool</font> example_client::<font color="#000000">setup_members(</font> <font color="#0000FF">uint</font> coid_stream_flags, netstream * bstream, binstream * bstream2, comm_mutex_reg * mx_reg )
<font color="#000080">{</font>
	<font color="#000000">disconnect(</font>);
	<font color="#000000">set_connection_type(</font> coid_stream_flags );

	<font color="#0000FF">if</font>( coid_stream_flags == ConnectFlags::fACCESS_MODE_DIRECT ) <font color="#000080">{</font>	<font color="#FF0000">/// direct</font>
		<font color="#0000FF">if</font>( ! bstream2 ) bstream2 = bstream;
		*bstream2 &gt;&gt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) _vtbl;
		*bstream2 &gt;&gt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) _me;
		comm_mutex_reg::refmutex * _rmx;
		*bstream2 &gt;&gt; (Tptr<font color="#000000">&lt;void&gt;</font> &amp;) _rmx;
		_mx_reg.<font color="#000000">init(</font> *_rmx );
		bstream2-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">delete</font> bstream;
	<font color="#000080">}</font>
	<font color="#0000FF">else</font> <font color="#0000FF">if</font>( coid_stream_flags == ConnectFlags::fACCESS_MODE_INTERPROCESS ) <font color="#000080">{</font>	<font color="#FF0000">/// interprocess</font>
		<font color="#0000FF">if</font>( ! bstream2 ) bstream2 = bstream;
		<font color="#0000FF">if</font>( coid_interprocess_vtbl ) _vtbl = coid_interprocess_vtbl;
		<font color="#0000FF">else</font> <font color="#000080">{</font>
			<font color="#000000">MXGUARD(</font> coid_table_mx );
			<font color="#0000FF">if</font>( ! coid_interprocess_vtbl )
				<font color="#000000">coid_init_table(</font> coid_stream_flags, coid_interprocess_vtbl );
			_vtbl = coid_interprocess_vtbl;
		<font color="#000080">}</font>
		_me = (COID_TABLE_example_0_0 *) <font color="#0000FF">new</font> <font color="#000000">example_localclient(</font> bstream, bstream2 );
		bstream2-&gt;<font color="#000000">acknowledge(</font>);
		_mx_reg.<font color="#000000">init(</font> mx_reg );
		_mx_reg._p1 = bstream;
	<font color="#000080">}</font>
	<font color="#0000FF">else</font> <font color="#0000FF">if</font>( coid_stream_flags == ConnectFlags::fACCESS_MODE_REMOTE ) <font color="#000080">{</font>	<font color="#FF0000">/// remote</font>
		<font color="#0000FF">if</font>( ! bstream2 ) bstream2 = bstream;
		<font color="#0000FF">if</font>( coid_remote_vtbl ) _vtbl = coid_remote_vtbl;
		<font color="#0000FF">else</font> <font color="#000080">{</font>
			<font color="#000000">MXGUARD(</font> coid_table_mx );
			<font color="#0000FF">if</font>( ! coid_remote_vtbl )
				<font color="#000000">coid_init_table(</font> coid_stream_flags, coid_remote_vtbl );
			_vtbl = coid_remote_vtbl;
		<font color="#000080">}</font>
		_me = (COID_TABLE_example_0_0 *) <font color="#0000FF">new</font> <font color="#000000">example_localclient(</font> bstream, bstream2 );
		bstream2-&gt;<font color="#000000">acknowledge(</font>);
		_mx_reg.<font color="#000000">init(</font> mx_reg );
		_mx_reg._p1 = bstream;
	<font color="#000080">}</font>
	<font color="#0000FF">else</font> <font color="#0000FF">throw</font> ersFE_EXCEPTION;

	<font color="#0000FF">return</font> <font color="#0000FF">true</font>;
<font color="#000080">}</font>

<font color="#0000FF">void</font> example_client::<font color="#000000">setup_stream(</font> binstream &amp; b, <font color="#0000FF">uint</font> coid_flags, <font color="#0000FF">uint</font> coid_obj_id )
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( coid_flags &amp; ConnectFlags::fWITHIN_CHANNEL ) <font color="#000080">{</font>
		coid_flags &amp;= ~ConnectFlags::fWITHIN_CHANNEL;
		b &lt;&lt; StdProtocolMethod::CONNECT;
	<font color="#000080">}</font>
	<font color="#0000FF">uchar</font> conchar = StdProtocolMethod::CONNECT_CHAR;
	b &lt;&lt; conchar &lt;&lt; <font color="#000000">version(</font>COID_VERSION);
	b &lt;&lt; g_coid_nick &lt;&lt; coid_flags &lt;&lt; COID_version_example_0_0 &lt;&lt; <font color="#000000">"example"</font>;
	b &lt;&lt; (<font color="#0000FF">uint</font>) <font color="#00D000">5</font> &lt;&lt; (Tptr<font color="#000000">&lt;void&gt;</font>) COID_method_flags_example &lt;&lt; coid_obj_id &lt;&lt; <font color="#000000">sysGetPid(</font>) &lt;&lt; (Tptr<font color="#000000">&lt;void&gt;</font>) <font color="#0000FF">this</font>;
<font color="#000080">}</font>








<font color="#0000FF">opcd</font> example_client::<font color="#000000">connect(</font>  <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; name, <font color="#0000FF">const</font> password &amp; pwd, <font color="#0000FF">const</font> <font color="#0000FF">char</font> * coid_address, <font color="#0000FF">uint</font> coid_flags )
<font color="#000080">{</font>
	_addr.<font color="#000000">reset(</font>);
	extendedGUARD_reg <font color="#000000">__coid__mxg(</font> _mx_reg, <font color="#0000FF">false</font> );
	<font color="#0000FF">if</font>( _mx_reg.<font color="#000000">is_valid(</font>) ) <font color="#000080">{</font>
		<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_DIRECT ) <font color="#000080">{</font>	<font color="#FF0000">/// direct</font>
			<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
		<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_INTERPROCESS ) <font color="#000080">{</font>	<font color="#FF0000">/// interprocess</font>
			__coid__mxg.<font color="#000000">lock(</font>);
			<font color="#0000FF">if</font>( ((COID_CLIENT *)_me)-&gt;<font color="#000000">is_stream_open(</font>) )
				<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
		<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_REMOTE ) <font color="#000080">{</font>	<font color="#FF0000">/// remote</font>
			__coid__mxg.<font color="#000000">lock(</font>);
			<font color="#0000FF">if</font>( ((COID_CLIENT *)_me)-&gt;<font color="#000000">is_stream_open(</font>) )
				<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
	<font color="#000080">}</font>

	netstream * _coid_bstream = COID_CLIENT::<font color="#000000">create_stream(</font> <font color="#000000">"example"</font>, coid_address, _addr, (coid_flags &amp; ConnectFlags::fTUNNEL) != <font color="#00D000">0</font> );
	<font color="#0000FF">if</font>( ! _coid_bstream ) <font color="#0000FF">return</font> ersFE_UNREACHABLE;
	coid_flags &amp;= ~ConnectFlags::fTUNNEL;
	<font color="#000000">setup_stream(</font> *_coid_bstream, coid_flags, UMAX );
	___COID_CONNECT_TRY
	*_coid_bstream &lt;&lt; name;
	*_coid_bstream &lt;&lt; pwd;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	<font color="#0000FF">opcd</font> _coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">delete</font> _coid_bstream;
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>

	<font color="#0000FF">uint</font> coid_stream_flags;
	*_coid_bstream &gt;&gt; coid_stream_flags;
	<font color="#000000">RASSERT(</font> coid_stream_flags &amp; ConnectFlags::xACCESS_MODE );
	<font color="#000000">setup_members(</font> coid_stream_flags, _coid_bstream, _coid_bstream );

	<font color="#0000FF">return</font> _coid_err_code;

	___COID_CONNECT_CATCH
<font color="#000080">}</font>








<font color="#0000FF">opcd</font> example_client::<font color="#000000">connect_within(</font>  comm_mutex_reg &amp; coid_channel, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; name, <font color="#0000FF">const</font> password &amp; pwd )
<font color="#000080">{</font>
	<font color="#0000FF">if</font>( ! coid_channel.<font color="#000000">is_set(</font>) ) <font color="#0000FF">return</font> ersFE_CHANNEL;
	_addr.<font color="#000000">reset(</font>);
	extendedGUARD_reg <font color="#000000">__coid__mxg(</font> coid_channel, <font color="#0000FF">true</font> );

	netstream * _coid_bstream = (netstream *) ((comm_mutex_custom_reg&lt;netstream, <font color="#0000FF">void</font>*&gt; &amp;) coid_channel)._p1;
	<font color="#0000FF">if</font>( ! _coid_bstream ) <font color="#0000FF">return</font> ersFE_UNREACHABLE;
	<font color="#FF0000">/// we must avoid direct access mode</font>
	<font color="#000000">setup_stream(</font> *_coid_bstream, ConnectFlags::fACCESS_MODE_REMOTE | ConnectFlags::fACCESS_MODE_INTERPROCESS | ConnectFlags::fWITHIN_CHANNEL, UMAX );
	___COID_CONNECTWITHIN_TRY
	*_coid_bstream &lt;&lt; name;
	*_coid_bstream &lt;&lt; pwd;

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	<font color="#0000FF">opcd</font> _coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>

	<font color="#0000FF">uint</font> coid_stream_flags;
	*_coid_bstream &gt;&gt; coid_stream_flags;
	<font color="#000000">RASSERT(</font> coid_stream_flags &amp; ConnectFlags::xACCESS_MODE );
	<font color="#000000">setup_members(</font> coid_stream_flags, _coid_bstream, _coid_bstream, &amp;coid_channel );

	<font color="#0000FF">return</font> _coid_err_code;

	___COID_CONNECTWITHIN_CATCH
<font color="#000080">}</font>






<font color="#0000FF">opcd</font> example_client::<font color="#000000">connect_shared(</font> <font color="#0000FF">uint</font> coid_obj_id,  <font color="#0000FF">const</font> <font color="#0000FF">char</font> * coid_address, <font color="#0000FF">uint</font> coid_flags  )
<font color="#000080">{</font>
	_addr.<font color="#000000">reset(</font>);
	extendedGUARD_reg <font color="#000000">__coid__mxg(</font> _mx_reg, <font color="#0000FF">false</font> );
	<font color="#0000FF">if</font>( _mx_reg.<font color="#000000">is_valid(</font>) ) <font color="#000080">{</font>
		<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_DIRECT ) <font color="#000080">{</font>	<font color="#FF0000">/// direct</font>
			<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
		<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_INTERPROCESS ) <font color="#000080">{</font>	<font color="#FF0000">/// interprocess</font>
			__coid__mxg.<font color="#000000">lock(</font>);
			<font color="#0000FF">if</font>( ((COID_CLIENT *)_me)-&gt;<font color="#000000">is_stream_open(</font>) )
				<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
		<font color="#0000FF">else</font> <font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) == ConnectFlags::fACCESS_MODE_REMOTE ) <font color="#000080">{</font>	<font color="#FF0000">/// remote</font>
			__coid__mxg.<font color="#000000">lock(</font>);
			<font color="#0000FF">if</font>( ((COID_CLIENT *)_me)-&gt;<font color="#000000">is_stream_open(</font>) )
				<font color="#0000FF">return</font> ersFE_ALREADY_CONNECTED;
		<font color="#000080">}</font>
	<font color="#000080">}</font>

	netstream * _coid_bstream = COID_CLIENT::<font color="#000000">create_stream(</font> <font color="#000000">"example"</font>, coid_address, _addr, (coid_flags &amp; ConnectFlags::fTUNNEL) != <font color="#00D000">0</font> );
	<font color="#0000FF">if</font>( ! _coid_bstream ) <font color="#0000FF">return</font> ersFE_UNREACHABLE;
	coid_flags &amp;= ~ConnectFlags::fTUNNEL;
	<font color="#000000">setup_stream(</font> *_coid_bstream, coid_flags, coid_obj_id );
	___COID_CONNECT_TRY

	_coid_bstream-&gt;<font color="#000000">flush(</font>);
	<font color="#0000FF">opcd</font> _coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
	<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
		_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#0000FF">delete</font> _coid_bstream;
		<font color="#0000FF">return</font> _coid_err_code;
	<font color="#000080">}</font>

	<font color="#0000FF">uint</font> coid_stream_flags;
	*_coid_bstream &gt;&gt; coid_stream_flags;
	<font color="#000000">RASSERT(</font> coid_stream_flags &amp; ConnectFlags::xACCESS_MODE );
	<font color="#000000">setup_members(</font> coid_stream_flags, _coid_bstream, _coid_bstream );

	<font color="#0000FF">return</font> _coid_err_code;

	___COID_CONNECT_CATCH
<font color="#000080">}</font>









<font color="#0000FF">opcd</font> example_client::<font color="#000000">read1(</font> FOO_STRUCT &amp; list )
<font color="#000080">{</font>
	<font color="#0000FF">opcd</font> _coid_err_code;
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#endif</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#0000FF">if</font>( ! _me ) <font color="#0000FF">return</font> ersFE_DISCONNECTED;
		_coid_err_code = (_me-&gt;*(_vtbl-&gt;read1__0)) (list);
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>_coid_err_code = e;<font color="#000080">}</font>
<font color="#000080">#endif</font>
	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">read2(</font> FOO_STRUCT &amp; list )
<font color="#000080">{</font>
	<font color="#0000FF">opcd</font> _coid_err_code;
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#endif</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#0000FF">if</font>( ! _me ) <font color="#0000FF">return</font> ersFE_DISCONNECTED;
		<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) != ConnectFlags::fACCESS_MODE_DIRECT )
			_coid_err_code = ((example_localclient *) _me)-&gt;<font color="#000000">read2 (</font>list);
		<font color="#0000FF">else</font> <font color="#000080">{</font>
			FOO_STRUCT * coidfetch_list;
			_coid_err_code = (_me-&gt;*(_vtbl-&gt;read2__1)) (coidfetch_list);
			<font color="#0000FF">if</font>( ! _coid_err_code ) <font color="#000080">{</font>
				list = *coidfetch_list;
			<font color="#000080">}</font>
		<font color="#000080">}</font>
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>_coid_err_code = e;<font color="#000080">}</font>
<font color="#000080">#endif</font>
	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">send(</font> <font color="#0000FF">int</font> &amp; ref, <font color="#0000FF">const</font> <font color="#0000FF">charstr</font> &amp; command, binstreambuf &amp; reply ) <font color="#0000FF">const</font>
<font color="#000080">{</font>
	<font color="#0000FF">opcd</font> _coid_err_code;
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#endif</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#0000FF">if</font>( ! _me ) <font color="#0000FF">return</font> ersFE_DISCONNECTED;
		_coid_err_code = (_me-&gt;*(_vtbl-&gt;send__2)) (ref, command, reply);
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>_coid_err_code = e;<font color="#000080">}</font>
<font color="#000080">#endif</font>
	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">remap_fnc(</font> REMAP_EXAMPLE_clientside &amp; remapped_arg )
<font color="#000080">{</font>
	<font color="#0000FF">opcd</font> _coid_err_code;
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#endif</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#0000FF">if</font>( ! _me ) <font color="#0000FF">return</font> ersFE_DISCONNECTED;
		<font color="#0000FF">if</font>( <font color="#000000">get_connection_type(</font>) != ConnectFlags::fACCESS_MODE_DIRECT )
			_coid_err_code = ((example_localclient *) _me)-&gt;<font color="#000000">remap_fnc (</font>remapped_arg);
		<font color="#0000FF">else</font> <font color="#000080">{</font>
			COID_CLIENT_EXESTREAM_ARGS <font color="#000000">args(</font> (<font color="#0000FF">void</font> *) _me, COID_example_remap_fnc_3 );
			_mexestream.<font color="#000000">reset(</font>);
			_mexestream.<font color="#000000">set_fnc(</font> (mexestream::mexestream_fnc) (_vtbl-&gt;remap_fnc__3), &amp;args );
			mexestream * _coid_bstream = &amp;_mexestream;
		
			_coid_bstream-&gt;<font color="#000000">flush(</font>);
			_coid_err_code = _coid_bstream-&gt;<font color="#000000">get_error(</font>);
			<font color="#0000FF">if</font>( _coid_err_code ) <font color="#000080">{</font>
				_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
				<font color="#0000FF">return</font> _coid_err_code;
			<font color="#000080">}</font>
			*_coid_bstream &gt;&gt; remapped_arg;
			_coid_bstream-&gt;<font color="#000000">acknowledge(</font>);
		<font color="#000080">}</font>
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>_coid_err_code = e;<font color="#000080">}</font>
<font color="#000080">#endif</font>
	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>

<font color="#0000FF">opcd</font> example_client::<font color="#000000">get_ptr(</font> FOO_STRUCT ** f )
<font color="#000080">{</font>
	<font color="#0000FF">opcd</font> _coid_err_code;
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#0000FF">try</font> <font color="#000080">{</font>
<font color="#000080">#endif</font>
		<font color="#000000">extendedGUARD_lock(</font> _mx_reg );
		<font color="#0000FF">if</font>( ! _me ) <font color="#0000FF">return</font> ersFE_DISCONNECTED;
		_coid_err_code = (_me-&gt;*(_vtbl-&gt;get_ptr__4)) (f);
<font color="#000080">#ifndef</font> example_NOTHROW
	<font color="#000080">}</font>
	<font color="#0000FF">catch</font>( <font color="#0000FF">opcd</font> e ) <font color="#000080">{</font>_coid_err_code = e;<font color="#000080">}</font>
<font color="#000080">#endif</font>
	<font color="#0000FF">return</font> _coid_err_code;
<font color="#000080">}</font>



<font color="#000080">}</font>	<font color="#FF0000">/// namespace coid</font>
</tt>
</pre>
